package cn.com.suiyi.shixingshengxian.home.adapter;

import android.content.Context;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.com.suiyi.shixingshengxian.R;
import cn.com.suiyi.shixingshengxian.home.bean.Vegetable;

/**
 * Created by hansen on 2016/7/19.
 */
public class HomeTopAdapter extends BaseQuickAdapter<Vegetable.DataBean> {
private RecyclerView recy;
    private Context context;
    private GridLayoutManager manager;

    public HomeTopAdapter(int layoutResId, List<Vegetable.DataBean> data, Context context) {
        super(layoutResId, data);
        this.context=context;
        manager=new GridLayoutManager(context,3);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        View v= LayoutInflater.from(context).inflate(layoutResId,null);
        RecyclerView recy= (RecyclerView) v.findViewById(R.id.vegetable_recyclerview);
        recy.setLayoutManager(manager);
    }

    public HomeTopAdapter(List<Vegetable.DataBean> data) {
        super(data);
    }

    public HomeTopAdapter(View contentView, List<Vegetable.DataBean> data) {
        super(contentView, data);
    }

    @Override
    protected int getDefItemViewType(int position) {
        return super.getDefItemViewType(position);
    }

    @Override
    protected void convert(BaseViewHolder helper, Vegetable.DataBean dataBean) {
        //     helper.setText(R.id.tweetName, item.getUserName())
//                .setText(R.id.tweetText, item.getText())
//                .setText(R.id.tweetDate, item.getCreatedAt())
//                .setVisible(R.id.tweetRT, item.isRetweet())
//                .linkify(R.id.tweetText);
//        Glide.with(mContext).load(item.getUserAvatar()).crossFade().into((ImageView) helper.getView(R.id.iv));
        helper.setText(R.id.vegetable_title,dataBean.getTitle());
        helper.setText(R.id.vegetable_Description,dataBean.getDescription());

        VegetableAdapter adapter=new VegetableAdapter(context,dataBean.getFloorItem());
        recy.setAdapter(adapter);

    }
}

